import {BaseService} from '../../base.service'
import {getVerifyId} from "../../auth/auth.service";
import Wrapper from "../../util";

export class CheckList extends BaseService {

  static addCheckList(data = window.required(), isShowNotification = true) {
    let verify_id = '?verify_id=' + getVerifyId();
    const wrapper = new Wrapper;
    return new Promise((resolve, reject) => {
      return this.request({auth: true}).post(`${this.entity}/addCheckList${verify_id}`, data).then(response => {
        wrapper.setWrapper(response, isShowNotification).then(() => {
          return resolve(response.data)
        }).catch(() => {
          return reject(response.data)
        })
      }).catch(error => {
        reject(console.log('addCheckList ' + this.entity, error))
      })
    })
  }

}

export class CostsService extends CheckList {
  static get entity() {
    return 'events/costs'
  }
}

export class TypesService extends BaseService {
  static get entity() {
    return 'events/costs/types'
  }
}

export class TemplatesService extends CheckList {
  static get entity() {
    return 'events/costs/templates'
  }
}

export class ItemsService extends BaseService {
  static get entity() {
    return 'events/costs/templates/items'
  }
}
